<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>
    let stNum = ['101', '102', '103']
    let stName = ['蔡徐坤', '红色风暴', '蓝色妖姬']
    let stScour = ['60', '70', '80']
    while (true) {
        let num = prompt('欢迎来到学生成绩管理系统，请根据提示输入：1.查询 2.新增 3.修改 4.删除 0.退出')
        if (num == '1') {
            let str = ''
            for (let i = 0; i < stNum.length; i++) {
                str += `学号：${stNum[i]}------姓名：${stName[i]}-------成绩：${stScour[i]}\n`
            }
            alert(str)
        }
        else if (num == '2') {
            let newStuNum = prompt('请输入新增的学生学号:')
            let newStuName = prompt('请输入新增的学生姓名:')
            let newStuScour = prompt('请输入新增的学生成绩:')
            stNum.push(newStuNum)
            stName.push(newStuName)
            stScour.push(newStuScour)//添加进原数组
        }
        else if (num == '3') {
            let a = prompt('请输入你要修改的学号')
            let b = stNum.indexOf(a)
            if (b != -1) {
                let te = prompt("改动学号")
                stNum.splice(b,1,te)   
                let ca = prompt('请输入你要更改的姓名')
                stName.splice(b, 1, ca)
                let qq = prompt('请输入你要更改的成绩')
                stScour.splice(b,1,qq)
            }
            else {
                alert('输入有误')
            }
        }
        else if (num == '4') {
            let ew = prompt("删除")
            let q1 = stNum.indexOf(ew)
            stNum.splice(q1, 1)
        }
        else if (num == '0') {alert("感谢使用本程序")
            break;
            
        }
        else {
            alert('输入错误')
        }
    }
</script>